<?php /* Smarty version 2.6.20, created on 2016-07-19 15:22:59
         compiled from huopin.htm */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'date_format', 'huopin.htm', 187, false),array('modifier', 'default', 'huopin.htm', 188, false),array('function', 'html_select_time', 'huopin.htm', 188, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>伙拼</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<?php if ($_GET['operation'] == 'add' || $_GET['operation'] == 'edit' || $_GET['operation'] == 'batch'): ?>
<script language="javascript" src="../script/Calendar.js"></script>
<?php else: ?>
<link href="cxcalendar.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../script/Calendar-new.js"></script>
<?php endif; ?>
<script src="../script/my_lightbox.js" language="javascript"></script>
<script language="javascript">
var weburl="<?php echo $this->_tpl_vars['config']['weburl']; ?>
";
$(function(){
	
	//时间搜索
	$('.input_cxcalendar').each(function(){
	    var a = new Calendar({
	        targetCls: $(this),
	        type: 'yyyy-mm-dd HH:MM:SS',
	        wday:2
	    },function(val){
	        console.log(val);
	    });
	});
	
	$('#form').validate({
		errorPlacement: function(error, element){
			element.next('.form-error').append(error);
		},      
		rules : {
			hp_title:{
				required:true
			},
			pic:{
				required:true
			},
			pid:{
				required:true
			},
			limit_amount:{
				required:true
			},
			low_amount:{
				required:true
			}
		},
		messages : {
			hp_title:{
				required:'请填写伙拼名称',
			},
			pic:{
				required:'请上传图片',
			},
			pid:{
				required:'请选择商品',
			},
			limit_amount:{
				required:'请填写',
			},
			low_amount:{
				required:'请填写',
			},
		}
	});
	
	$('#pid').bind('click change',function(){
	var $$=$(this);
	//alert($$.val());

	if(!$$.val()){return false;}


	if(/[^\d]/.test($$.val())){

		alert('请输出正确的产品id');
		$(this).val('');
		return false;

	}

	$.getJSON('?m=huopin&s=huopin.php&operation=getsku&pid='+$$.val()+'&hp_id='+$('#id').val(),function(data){
		if (!data) {alert('未找到此商品，请确认商品已上架');return false;}
			var str='<table width="100%" class="alc"><tbody><tr><th width="100" align="left">产品图</th><th width="350">产品名称</th><th width="200" align="left">规格</th><th>产品价格</th><th>分销价</th><th>伙拼价格</th><th>建议零售价</th><th width="100">伙拼库存</th><th width="100">已售</th><th width="100">是否伙拼此sku</th></tr>';
				$.each(data,function(k,v){
					str+='<tr><td><img width="50" src="'+v.pic+'"></td>';
					str+='<td class="al"><input type="hidden" name="skuid[]" value="'+v.id+'"><input type="hidden" name="stock_shop[]" value="'+v.stock_shop+'"><div class="name">'+v.pname+'</div></td>';
				  str+='<td><div class="name">'+v.spec+'</div></td>';
				  str+='<td>'+v.price+'</td>';
				   str+='<td>'+v.dis_price+'</td>';
				  str+='<td><input type="text" style="width:80px;" name="hp_price[]" value="'+v.hp_price+'"></td>';
				 str+='<td><input type="text" style="width:80px;" name="hp_market_price[]" value="'+v.hp_market_price+'"></td>';
				  str+='<td align="center"><input type="text" style="width:50px;" name="hp_stock[]" value="'+v.hp_stock+'"></td>';
				   str+='<td align="center">'+v.hp_amount+'</td>';
				    str+='<td align="center"><input type="checkbox" value="1" style="float:none;" name="sku_status['+k+']" '+(v.hp_status>-1?'checked':'')+'></td>';
					});
		      
       str+='</tbody></table>';

       $('#pid_span').html(str).show();


		



		})


	
})


 <?php if ($_GET['operation'] == 'edit'): ?>
 $('#pid').click();
                    <?php endif; ?>

});
<?php if ($_GET['operation'] == 'add' || $_GET['operation'] == 'edit' || $_GET['operation'] == 'batch'): ?>
                    var cdr = new Calendar("cdr");
                    document.write(cdr);
                    cdr.showMoreDay = true;
<?php endif; ?>
</script>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>伙拼商品</h3>
                <ul>
                    <li <?php if ($_GET['operation'] == ''): ?>class="current"<?php endif; ?>><a href="?m=<?php echo $_GET['m']; ?>
&s=<?php echo $_GET['s']; ?>
"><span>管理</span></a></li>
                    <li <?php if ($_GET['operation'] == 'add'): ?>class="current"<?php endif; ?>><a href="?m=<?php echo $_GET['m']; ?>
&s=<?php echo $_GET['s']; ?>
&operation=add"><span>添加</span></a></li>
                    <?php if ($_GET['operation'] == 'edit'): ?>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <?php endif; ?>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <?php if ($_GET['operation'] == 'add' || $_GET['operation'] == 'edit' || $_GET['operation'] == 'batch'): ?>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<?php echo $this->_tpl_vars['de']['id']; ?>
">
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">伙拼</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">伙拼名称</td>
                    <td>
                    <input name="hp_title" id="hp_title" type="text" class="w350" value="<?php echo $this->_tpl_vars['de']['hp_title']; ?>
">
                 	<div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td>选择商品</td>
                    <td>
                    <input type="text" value="<?php echo $this->_tpl_vars['de']['pid']; ?>
" name="pid" id="pid" > 请输入产品id
                    <div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                <tr>
        <td colspan="2" id="pid_span" style="display:none;">
        </td>
        </tr>
                <tr>
                    <td>伙拼图片</td>
                    <td>
                    <input name="pic" class="w350" type="text" id="pic" value="<?php echo $this->_tpl_vars['de']['pic']; ?>
" /><div id="form-error" class="form-error"></div>
                    [<a href="javascript:uploadfile('上传LOGO','pic',0,0,'huopin')">上传</a>] 
                    [<a href="javascript:preview('pic');">预览</a>]
                    [<a onclick="javascript:$('#pic').val('');" href="#">删除</a>] <span class="bz"></span>
                    </td>
                </tr>
                <tr>
                    <td>起止时间</td>
                    <td>
                    
                    <input onFocus="cdr.show(this);" class="ltext" type="text" name="stime" id="stime" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['de']['start_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp) : smarty_modifier_date_format($_tmp)); ?>
"> 
                    <?php echo smarty_function_html_select_time(array('use_24_hours' => true,'display_seconds' => false,'display_minutes' => false,'prefix' => 'start','time' => ((is_array($_tmp=@$this->_tpl_vars['de']['start_time'])) ? $this->_run_mod_handler('default', true, $_tmp, 0) : smarty_modifier_default($_tmp, 0))), $this);?>
:00:00
                    - 
                    <input onFocus="cdr.show(this);" class="rtext" type="text" name="etime" id="etime" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['de']['end_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp) : smarty_modifier_date_format($_tmp)); ?>
">
                    <?php echo smarty_function_html_select_time(array('use_24_hours' => true,'display_seconds' => false,'display_minutes' => false,'prefix' => 'end','time' => ((is_array($_tmp=@$this->_tpl_vars['de']['end_time'])) ? $this->_run_mod_handler('default', true, $_tmp, '23:59:59') : smarty_modifier_default($_tmp, '23:59:59'))), $this);?>
:59:59
                    </td>
                </tr>
                <tr>
                    <td>最小起购数量</td>
                    <td><input type="text" name="limit_amount" value="<?php if ($this->_tpl_vars['de']['limit_amount']): ?><?php echo $this->_tpl_vars['de']['limit_amount']; ?>
<?php else: ?>1<?php endif; ?>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /><div id="form-error" class="form-error"></div><p class="hint">每个会员单次购买最小件数</p></td>
				</tr>
                
                <tr>
                    <td>虚拟数量</td>
                    <td><input type="text" name="virtual_amount" value="<?php if ($this->_tpl_vars['de']['virtual_amount']): ?><?php echo $this->_tpl_vars['de']['virtual_amount']; ?>
<?php else: ?>0<?php endif; ?>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /><p class="hint">虚拟购买数量，只用于前台显示，不影响成交记录</p></td>
				</tr>
                
                <tr>
                    <td>伙拼成功数量</td>
                    <td><input type="text" name="low_amount" value="<?php if ($this->_tpl_vars['de']['low_amount']): ?><?php echo $this->_tpl_vars['de']['low_amount']; ?>
<?php else: ?>1<?php endif; ?>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')"/><div id="form-error" class="form-error"></div><p class="hint">伙拼达到此数量的时候显示伙拼成功</p></div></td>
				</tr> 
                <tr>
                    <td>状态</td>
                    <td>
                    <?php if ($_GET['operation'] == 'edit'): ?><input type="radio" name="status" value="3" id="done" <?php if ($this->_tpl_vars['de']['status'] == 3): ?>checked="checked"<?php endif; ?>/><label for="done">已完成</label><?php endif; ?>
                    <?php if ($_GET['operation'] == 'edit'): ?><input type="radio" name="status" value="2" id="tj" <?php if ($this->_tpl_vars['de']['status'] == 2): ?>checked="checked"<?php endif; ?>/><label for="tj">备货中</label><?php endif; ?>
                    <input type="radio" name="status" value="1" id="open" <?php if ($this->_tpl_vars['de']['status'] == 1): ?>checked="checked"<?php endif; ?>/><label for="open">开启</label>
                    <input type="radio" name="status" value="0" id="close" <?php if ($this->_tpl_vars['de']['status'] == 0): ?>checked="checked"<?php endif; ?>/><label for="close">关闭</label>
                    </td>
                </tr>
               
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<?php if (! $_GET['editid']): ?>save<?php else: ?>edit<?php endif; ?>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
        <?php else: ?>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        
        <form action="" method="get">
	    <input type="hidden" name="m" value="<?php echo $_GET['m']; ?>
">
	    <input type="hidden" name="s" value="<?php echo $_GET['s']; ?>
">
	    <table class="select_table">
	        <tr>    
	           <td>
	                    <span>&nbsp;产品ID:</span>
           				<span>
           					<input name="productId" value="<?php echo $_GET['productId']; ?>
" />
           				</span>
           				<span>&nbsp;伙拼ID:</span>
           				<span>
           					<input name="hpId" value="<?php echo $_GET['hpId']; ?>
" />
           				</span>
	                    <span>&nbsp;伙拼状态:</span>
	                    <span>
	                    	<select name="hp_status">
	                    		<option value="">全部</option>
	                    		<option value="1" <?php if ($_GET['hp_status'] == '1'): ?>selected<?php endif; ?> >伙拼中</option>
	                    		<option value="8" <?php if ($_GET['hp_status'] == '8'): ?>selected<?php endif; ?> >未开始</option>
	                    		<option value="2" <?php if ($_GET['hp_status'] == '2'): ?>selected<?php endif; ?> >伙拼中(已成功)</option>
	                    		<option value="3" <?php if ($_GET['hp_status'] == '3'): ?>selected<?php endif; ?> >伙拼结束(已成功)</option>
	                    		<option value="4" <?php if ($_GET['hp_status'] == '4'): ?>selected<?php endif; ?> >伙拼结束(已失败)</option>
	                    		<option value="5" <?php if ($_GET['hp_status'] == '5'): ?>selected<?php endif; ?> >配货中</option>
	                    		<option value="6" <?php if ($_GET['hp_status'] == '6'): ?>selected<?php endif; ?> >已完成</option>
	                    		<option value="7" <?php if ($_GET['hp_status'] == '7'): ?>selected<?php endif; ?> >已关闭</option>
	                    	</select>
	                    </span>
	                    <span>&nbsp;伙拼时间：</span>
	                    <span>
	                            <input class="w120 input_cxcalendar" type="text" name="stime" id="stime" value="<?php echo $_GET['stime']; ?>
">
	                            -
	                            <input class="w120 input_cxcalendar" type="text" name="etime" id="etime" value="<?php echo $_GET['etime']; ?>
">
	                    </span>
	                    <span>&nbsp;状态:</span>
	                    <span>
	                    	<select name="status">
	                    		<option value="">不限</option>
	                    		<option value="1" <?php if ($_GET['status'] == '1'): ?>selected<?php endif; ?> >开启</option>
	                    		<option value="2" <?php if ($_GET['status'] == '2'): ?>selected<?php endif; ?> >备货中</option>
	                    		<option value="3" <?php if ($_GET['status'] == '3'): ?>selected<?php endif; ?> >已完成</option>
	                    		<option value="4" <?php if ($_GET['status'] == '4'): ?>selected<?php endif; ?> >已关闭</option>
                    		</select>
                   		</span>
                   		
                   		<input style="margin-left:30px;" type="submit" value="搜索" />
	           </td>
	        </tr>
	    </table>
	    </form>
        
        <form action="" method="post">
        <table class="table">
        	<thead>
                <tr>
                    <th class="partition" colspan="99"></th>
                </tr>
            </thead>
            <tbody>
                <tr class="header">
                    <th width="30"></th>
                    <th width="30">显示顺序</th>
                    <th width="30">ID</th>
                    <th width="80">图片</th>
                    <th width="100">伙拼名称</th>
                    <th width="50">商品ID</th>
                    <th width="50">伙拼价格</th>
                    <th width="50">零售价</th>
                    <th width="50">伙拼库存</th>
                    <th width="50">最低起售数</th>
                    <th width="60">实际已售数量</th>
                    <th width="50">虚拟数量</th>
                    <th width="100">火拼成功数量</th>
                    <th width="50">开始时间</th>
                    <th width="50">结束时间</th>
                    <th width="50">伙拼状态</th>
                    <th width="50">状态</th>
                    <th width="50"></th>
                </tr>
                <?php $_from = $this->_tpl_vars['de']['list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
                <tr>
                    <td><input type="checkbox" value="<?php echo $this->_tpl_vars['list']['id']; ?>
" class="checkitem" name="chk[]"></td>
                    <td><input type="text" class="w50" maxlength="3" name="displayorder[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['displayorder']; ?>
" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /></td>
                    <td><?php echo $this->_tpl_vars['list']['id']; ?>
</td>
                    <td width="80"><?php if ($this->_tpl_vars['list']['pic']): ?><img width="100" height="60" class="img" src="<?php echo $this->_tpl_vars['list']['pic']; ?>
/80" /><?php else: ?><img class="img" width="60" src="../image/default/nopic.gif" /><?php endif; ?></td>
                    <td width="100"><?php echo $this->_tpl_vars['list']['hp_title']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['pid']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['config']['money']; ?>
<?php echo $this->_tpl_vars['list']['price']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['config']['money']; ?>
<?php echo $this->_tpl_vars['list']['market_price']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['stocks']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['limit_amount']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['true_amount']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['virtual_amount']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['low_amount']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['start_time']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['end_time']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['hpStatusStr']; ?>
</td>
                    <td><?php if ($this->_tpl_vars['list']['status'] == 1): ?>开启<?php elseif ($this->_tpl_vars['list']['status'] == 2): ?>备货中<?php elseif ($this->_tpl_vars['list']['status'] == 3): ?>已完成<?php else: ?>关闭<?php endif; ?></td>
                    <td>
                    <a href="?m=<?php echo $_GET['m']; ?>
&s=<?php echo $_GET['s']; ?>
&operation=edit&editid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['editimg']; ?>
</a> 
                    </td>
                </tr>
                <?php endforeach; else: ?>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <?php endif; unset($_from); ?>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="4">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" name="submit" value="<?php echo $this->_tpl_vars['lang']['btn_submit']; ?>
" />
                        <input type="submit" name="submit" value="备货中" />
                        <input type="submit" name="submit" value="<?php echo $this->_tpl_vars['lang']['btn_open']; ?>
" />
                        <input type="submit" name="submit" onclick="return confirm('您确定要设置为完成吗');" value="完成" />
                        <input type="submit" name="submit" onclick="return confirm('您确定要关闭吗');" value="<?php echo $this->_tpl_vars['lang']['btn_close']; ?>
" />
                        <input type="submit" name="submit" onclick="return confirm('您确定要删除吗');" value="<?php echo $this->_tpl_vars['lang']['del']; ?>
" />
                    </td>
                    <td colspan="99"><div class="page"><?php echo $this->_tpl_vars['de']['page']; ?>
</div></td>
                </tr>
            </tfoot>
        </table>
        </form>
        <?php endif; ?>
    </div>
</body>
</html>